<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>操行管理</title>
    <meta name="context-path" th:content="@{/}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap-responsive.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-style.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-media.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-full.css}"/>
    <link rel="stylesheet" th:href="@{/resources/jquery-easyui/themes/metro/easyui.css}" />
    <link rel="stylesheet" th:href="@{/resources/matrix/font-awesome/css/font-awesome.css}"/>
    <link rel="stylesheet" th:href="@{/resources/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/resources/css/website.css}"/>
    <style>
        .layui-table-click{
            background-color: #FF7F24;
        }
    </style>
</head>
<body class="childbody">
<div class="container-fluid">
    <!--Chart-box-->
    <div class="row-fluid">
        <div class="widget-box">
            <div class="widget-title bg_lg"><span class="icon"><i class="icon-search"></i></span>
                <h5>查询</h5>
            </div>
            <div class="widget-content nopadding">
                <form id="queryform" action="#" method="get" class="form-horizontal query-form">
                    <div class="row-fluid query-row">
                        <div class="span8">
                            <div class="control-group">
                                <label class="control-label query-control-label">操行细则：</label>
                                <div class="controls query-controls">
                                    <input type="text" name="name" id="name" class="span11" placeholder="请输入操行细则">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row-fluid query-row">
                        <div class="span3">
                            <div class="control-group">
                                <label class="control-label">学校：</label>
                                <div class="controls form-group">
                                    <select class="span6 form-control" id="county" name="schoolId" th:value="schoolId" >
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button id="btnSearch" type="button" class="btn btn-primary">查询</button>
                        <button id="btnResetSearch" type="button" class="btn btn-info">重置</button>
                    </div>
                </form>
            </div>
        </div>
        <!--End-Chart-box-->
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-th"></i> </span>
                        <h5>操行</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <div class="table_actions">
                            <button id="btnAdd" class="btn  btn-primary">添加</button>
                            <button id="btnEdit" class="btn btn-info">修改</button>
                            <button id="btnView" class="btn btn-success">查看</button>
                            <button id="btnDelete" class="btn btn-danger">删除</button>
                            <button id="btnExport" class="btn btn-primary">导出</button>
                            <button id="btnImport"  type="button"  class="btn btn-success">导入</button>
                        </div>
                        <table id="tablelist" class="layui-table" lay-filter="question_list">
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/resources/js/jquery.min.js}"></script>
<script th:src="@{/resources/js/jquery-migrate-1.2.1.js}"></script>
<script th:src="@{/resources/jquery-easyui/jquery.easyui.min.js}"></script>
<script th:src="@{/resources/layui/layui.all.js}" charset="utf-8"></script>
<script th:src="@{/resources/valid/js/bootstrapValidator.js}"></script>
<script th:src="@{/resources/valid/js/language/zh_CN.js}"></script>
<script th:src="@{/resources/js/website.js}"></script>
<script th:src="@{/resources/js/system.js}"></script>
<script th:src="@{/resources/js/validation_fields.js}"></script>
<script th:src="@{/resources/uploader/AjaxFileUpload/ajaxfileupload.js}"></script>
<script th:src="@{/resources/js/upload.js}"></script>
<script th:inline="javascript">
    var contextRoot = $("meta[name='context-path']").attr("content");

    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            search();
        }
    });
</script>

<script th:inline="javascript">
    /*<![CDATA[*/

    var ListViewConductItem = function (layer, params, query) {
        var self = this;
        self.title = params.title;
        self.url = params.url;
        self.width = params.width;
        self.height = params.height;
        self.isfull = params.isfull ? true : false;
        self.layerIndex = null;
        self.openDialog = function () {
            var schoolId = $("input[name='schoolId']").val();
            console.log(schoolId);
            self.layerIndex = layer.open({
                type: 2,
                title: self.title,
                shadeClose: true,
                skin: 'layui-layer-lan',
                offset: '20px',
                shade: 0.8,
                area: [self.width, self.height],
                content: self.url + "/" + schoolId,
                maxmin: self.isfull
            });
            if (self.isfull == true) {
                layer.full(self.layerIndex);
            }
        }
        self.closeDialog = function () {
            layer.close(self.layerIndex);
        };
        self.editCompleted = function () {
            self.closeDialog();
            query.reload();
        }
    };

    var ListImportConductItem = function (layer, params, query) {
        var self = this;
        self.title = params.title;
        self.url = params.url;
        self.width = params.width;
        self.height = params.height;
        self.getUrl = params.getUrl;
        self.layerIndex = null;
        self.openDialog = function () {
            var tempUrl = self.url;
            if (self.getUrl) {
                tempUrl = self.getUrl(self.url);
            }
            var schoolId = $("input[name='schoolId']").val();
            self.layerIndex = layer.open({
                type: 2,
                title: self.title,
                shadeClose: true,
                skin: 'layui-layer-lan',
                shade: 0.8,
                offset: '20px',
                area: [self.width, self.height],
                content: tempUrl+ "/" + schoolId,
            });
        };
        self.closeDialog = function () {
            layer.close(self.layerIndex);
        };
        self.addCompleted = function () {
            self.closeDialog();
            query.reload();
        }
    };

    var query, add, edit,view,importExcel, del,release, queryItem, addItem,editItem,exports, queryOption,addOption,editOption,deleteItem,deleteOption, questionId,questionItemId,disabled ,doTop ,cancelTop;
    layui.use(['jquery', 'layer', 'table', 'laydate'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            table = layui.table;

        lay('.date').each(function () {
            laydate.render({
                elem: this
            });
        });

        var cols = [
            [
                {type: 'checkbox'},
                {field: 'name', width: '40%', title: '操行细则', sort: true},
                {field: 'score', width: '20%',title: '分数', sort: true},
                {field: 'schoolName', width: '20%',title: '学校', sort: true},
                {field: 'createTime', width: '15%', title: '创建时间', sort: true}
            ]
        ];

        query = new ListQuery(table, {
            cols: cols,
            element: "#tablelist",
            url: contextRoot + "schoolConductItem/doListSchoolConductItem",
            page: 1,
            even:false,
            filter: "question_list",
            tableid: "point_schoolConductIte_list_table",
            extraData: function () {
                return $("#queryform").serializeObject();
            },
            onRowChecked: function (row) {
                questionId = row.data.id;
                queryItem.reload();
            },
            onReload: function () {
                questionId = null;
            }
        });
        var schoolId = [[${user.orgId}]];
        var treeLevel = [[${treeLevel}]];

        if(treeLevel!=0){
            $("#btnResetSearch").hide();
            $("#county").attr("readOnly",true);
            $("#county").hide();
        }
        $('#county').combotree({
            url: contextRoot + "jwOrg/doListTreeOrgParent",
            required: true
        });
        $("#county").combotree('setValues',schoolId);
        if(treeLevel==0){
            $("#btnResetSearch").show();
        }
        query.reload();

        add = new ListAdd(layer, {
            title: "添加操行",
            url: contextRoot + "schoolConductItem/getAddSchoolConductItem",
            width: "860px",
            height: "550px"
        }, query);

        importExcel = new ListImportConductItem(layer, {
            title: "导入操行",
            url: contextRoot + "schoolConductItem/goFileUpload",
            width: "860px",
            height: "350px"
        }, query);

        edit = new ListEdit(layer, {
            title: "修改操行",
            url: contextRoot + "schoolConductItem/getUpdateItem",
            width: "860px",
            height: "550px"
        }, query);

        view = new ListViewConductItem(layer, {
            title: "查看操行",
            url: contextRoot + "schoolConductItem/getViewSchoolConduct",
            width: "860px",
            height: "750px"
        }, query);

        del = new ListDelete(layer, query, {
            url: contextRoot + "schoolConductItem/doDeleteItem"
        });

        exports = new ListExport(layer, {
            url: contextRoot + "schoolConductItem/exportConductItemLists",
            confirmText : "是否导出数据",
            extraData: function () {
                return $("#queryform").serializeObject();
            }
        });


        $("#btnAdd").bind("click", function (event) {
            add.openDialog();
        });

        $("#btnImport").bind("click", function (event) {
            importExcel.openDialog();
        });

        $("#btnSearch").bind("click", function (event) {
            query.reload();
        });

        $("#btnEdit").bind("click", function (event) {
            edit.openDialog();
        });

        $("#btnView").bind("click", function (event) {
            view.openDialog();
        });

        $("#btnDelete").bind("click", function (event) {
            del.submit();
        });

        $("#btnResetSearch").bind("click", function (event) {
            $("#name").val("");
            $("#county").combotree('setValues',"");
        });

        $("#btnExport").bind("click", function (event) {
            exports.export();
        });

    });



    /*]]>*/
</script>
</body>
</html>